#!/usr/bin/perl -w

use strict;

use Term::ANSIColor;
# use Win32::Console::ANSI;

my $string  = "Teszt szoveg";
my $color   = "\e[1;34m$string\e[0m";
my $colored = colored("$string", "red");

print "---------------\n";

print "$string\n";
print "$color\n";
print "$colored\n";

print "---------------\n";

print "length ".length($string)."\n";
print "length ".length($color)."\n";
print "length ".length($colored)."\n";

print "---------------\n";

print "length2 ".&colorLength($string)."\n";
print "length2 ".&colorLength($color)."\n";
print "length2 ".&colorLength($colored)."\n";

print "---------------\n";

sub colorLength($)  {
 
  my $str = $_[0];
  my $cnt = 0;

  $str =~ s/\e\[.+?m//g;
  
  while ( $str =~ /./g ) { $cnt++ };
    
  return $cnt;  
    
}
